#include"Common.hpp"
#include<unistd.h>



int main()
{
    //创建命名管道
    Fifo fifo(Path);

    int rfd=open(Path, O_RDONLY);

    if (rfd==-1)
    {
        cerr<<"open fifo failed"<<endl;
        return -1;
    }

    cout<<"open fifo success"<<endl;

    char buffer[1024];
    while (true)
    {
        ssize_t n=read(rfd, buffer, sizeof(buffer)-1);

        if (n==-1)
        {
           buffer[n]=='\0';
           cout<<"Client say: "<<buffer<<endl;
        }
        else if (n==0)
        {
            cerr<<"Client quit,me quit too"<<endl;
            break;
        }
        else
        {
           cerr<<"read failed"<<endl;
           break;

        }
    }
    
    close(rfd);
    return 0;
    
}

